package com.fivetalks.dao;


import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.fivetalks.domain.Member;
import com.fivetalks.repository.hibernate.HibernateGenericRepository;


@Repository(value = "memberDAO")
public class MemberDAO extends HibernateGenericRepository<Member>{
	public MemberDAO(){

	}
	public boolean rowExists(String column, String data) {
		Criteria criteria = getCriteria();
		criteria.setProjection(Projections.property(column));
		criteria.add(Restrictions.eq(column, data));
		
		String retData = (String) criteria.uniqueResult();
		if( retData == null  || retData == "" ) {
			getCurrentSession().clear();
			return false;
		}else{
			getCurrentSession().clear();
			return true;
		}
	}
	
	public boolean rowExists2(String column1, String data1,
			String column2, String data2) {
		Criteria criteria = getCriteria();
		criteria.setProjection(Projections.property(column1));
		criteria.add(Restrictions.eq(column1, data1));
		criteria.add(Restrictions.eq(column2, data2));
		
		String retData = (String) criteria.uniqueResult();
		if( retData == null  || retData == "" ) {
			getCurrentSession().clear();
			return false;
		}else{
			getCurrentSession().clear();
			return true;
		}
	}
	
}
